#pragma once

#include <QtWidgets/QWidget>
#include "ui_TCPServerContainer.h"
#include <QTimer>

QT_BEGIN_NAMESPACE
namespace Ui { class TCPServerContainerClass; };
QT_END_NAMESPACE

class TCPClient;
class TCPServerContainer : public QWidget
{
    Q_OBJECT

public:
    TCPServerContainer(QWidget *parent = nullptr);
    ~TCPServerContainer();

private:

	void OnServerClientConnected(TCPClient* client);

	void OnServerClientDisconnected(TCPClient* client);

	void OnServerClientReceived(TCPClient* client, char* data, int len);


	void OnConnectCompleted(int code, std::string error);

	void OnDisconnected();

	void OnReceived(char* data, int len);



private slots:

    void Tick();

    void on_StartButton_clicked();

    void on_StopButton_clicked();

    void on_TestButton_clicked();

private:
    Ui::TCPServerContainerClass *ui;
    QTimer* timer = nullptr;
    int64_t lastts = 0;
};
